#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <BEntry>
#include <BIcon>
#include <BImage>
#include <BButton>
#include <BLineEdit>
#include <BTreeWidget>
#include <BTabWidget>
#include <BFileDialog>
#include <BMenuBar>
#include <BMenu>
#include <BYamlNode>
#include <BMainWindow>

using namespace BWE;

class HeadInfo : public BThing
{
public:
	BEntryHolder	headEntry;
	BEntryHolder	htmlEntry;
};

class MainWindow : public BMainWindow
{
public:
	MainWindow();
	~MainWindow();

protected:
	void initMenuBar();
	bool openHtmlFile(const BString& htmlFileName);
	void signTitleChanged(BWidget* widget, bool changed);

protected:
	void slotHeadItemRightClicked(BObject* object, const BValue& value);
	void slotHeadItemDoubleClicked(BObject* object, const BValue& value);

	void slotTabCurrentChanged(BObject* object, const BValue& value);
	void slotTabClicked(BObject* object, BValue& value);
	void slotTabRightClicked(BObject* object, BValue& value);

	void slotTabClosing(BObject* object, BValue& value);
	void slotRemoveButtonClicked(BObject* object, const BValue& value);

	void slotNewActionTriggered(BObject* object, const BValue& value);
	void slotOpenActionTriggered(BObject* object, const BValue& value);
	void slotSaveActionTriggered(BObject* object, const BValue& value);
	void slotSaveAsActionTriggered(BObject* object, const BValue& value);
	void slotSaveAllActionTriggered();
	void slotCloseActionTrigger(BObject* object, const BValue& value);
	void slotPageMenuTrigger(BObject* object, const BValue& value);
	void slotTableMenuTrigger(BObject* object, const BValue& value);
	void slotTabMenuTrigger(BObject* object, const BValue& value);

	void slotHtmlItemClicked(BObject* object, const BValue& value);
	void slotHtmlItemRightClicked(BObject* object, const BValue& value);
	void slotHtmlItemChanged(BObject* object, const BValue& value);

	void slotMenuAddTrigger(BObject* object, const BValue& value);
	void slotMenuPrependTrigger(BObject* object, const BValue& value);
	void slotMenuAppendTrigger(BObject* object, const BValue& value);

protected:
	virtual void updateEvent(const BEvent& event);

	virtual void styleEvent(const BEvent& event);

private:
	BMenuBar*				_menuBar;
	BMenu*					_fileMenu;
	BMenu*					_editMenu;
	BMenu*					_viewMenu;
	BMenu*					_toolMenu;

	BButton*				_openButton;
	BButton*				_saveButton;
	BButton*				_saveAllButton;
	BButton*				_removeButton;

	BTreeWidget*			_workspace;
	BTabWidget*				_tabWidget;

	BFileDialog*			_fileDialog;
	BMenu*					_listMenu;
	BMenu*					_pageMenu;
	BMenu*					_tableMenu;
	BMenu*					_tabMenu;

	BFolder					_includeFolder;
	BFolder					_documentFolder;

	BImageHolder			_normalImage;
	BImageHolder			_dirtyImage;
	BImageHolder			_emptyImage;

	BIconHolder				_htmlIcon;
	BIconHolder				_textIcon;
	BIconHolder				_treeIcon;
};

#endif